package com.yyt.module_main.home;

import android.databinding.DataBindingUtil;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;

import com.yyt.module_main.R;
import com.yyt.module_main.databinding.FragmentHomeBinding;
import com.yyt.module_main.databinding.ItemHomeBinding;

import java.util.ArrayList;

import top.lixb.libcommon.base.BaseFragment;
import top.lixb.libcommon.base.ItemHolder;
import top.lixb.libcommon.base.RefreshableFragment;
import top.lixb.libcommon.base.SimpleBindingAdapter;
import top.lixb.libcommon.log.L;

public class HomeFragment extends RefreshableFragment<FragmentHomeBinding> {
    @Override
    protected void init() {
        mRefreshContentBinding.rv.setLayoutManager(new LinearLayoutManager(getActivity()));
        SimpleBindingAdapter<String, ItemHomeBinding> adapter = new SimpleBindingAdapter<String, ItemHomeBinding>(R.layout.item_home){
            @Override
            public void bind(@NonNull ItemHolder<ItemHomeBinding> holder, String bean) {
                holder.getBinding().setItem(bean);
            }
        };
        mRefreshContentBinding.rv.setAdapter(adapter);
        ArrayList<String> data = new ArrayList<>();
        data.add("测试1");
        data.add("测试2");
        data.add("测试3");
        data.add("测试4");
        data.add("测试5");
        data.add("测试6");
        data.add("测试7");
        data.add("测试8");
        adapter.setNewData(data);
    }

    @Override
    protected int initRefreshLayout() {
        return R.layout.fragment_home;
    }

    @Override
    protected void getData(boolean refresh) {

    }
}
